<?php

class PaymentAuctions extends PaymentData {
	
	public $auctionId;
	protected $_auctionAr;
	public $auctionImage;
	
	public function __construct(){
		$this->setName('auction');		
		$this->_auctionAr = new Auctions();
	}
	
	public function setAuctionId($aucitonId){
		$this->auctionId = $aucitonId;
		$auctionInfo = $this->_auctionAr->with(array('aoneimage','aoneimage.imageurl'))->find('t.id = '.$aucitonId);
		if(empty($auctionInfo)){

			return false;
		}
		$this->auctionImage = CHtml::value($auctionInfo, "aoneimage.imageurl.thumbnail_path");
		$this->_auctionAr = $auctionInfo;
		return $this;
	}
	
	public function vaild(){
		if (empty($this->auctionId)){
			$this->setErrorMessage('auctionId','auctionId NO');
		}
		
// 		$aids = array('101489','101249');
		// if( (time()-$this->expires_time>=$this->paynow_expired_time) && (time()-$this->expires_time>=$this->buyitnow_expired_time)){
		// 	$this->setErrorMessage('auction order ','auction Order Expired');
		// }
		
		return $this->vaild;
	}
	
	public function toArray(){
		$toArray = $this->_auctionAr->attributes;
		$toArray['auctionId'] = $this->auctionId;
		$toArray['auctionImage'] = $this->auctionImage;
		return $toArray;
	}
	
	public function __get($value){
		return $this->_auctionAr->$value;
	}
	
	public function __set($key,$value){
		return $this->_auctionAr->$key = $value;
	}

}
